package com.guigu.qingcheng.controller;

import com.guigu.qingcheng.pojo.TbUser;
import com.guigu.qingcheng.service.UserServiceFeign;
import com.guigu.qingcheng.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class RegisterController {

    @Autowired
    private UserServiceFeign userServiceFeign;

    // 转注册页面
    @RequestMapping("/registerUI")
    public String registerUI() {
        return "register";
    }

    //处理发送验证码的请求
    @GetMapping("/sendSms")
    @ResponseBody
    public R sendSms(String phone) {
        userServiceFeign.sendSms(phone);
        return  R.ok();
    }


    //处理用户注册的请求
    @PostMapping("/save")
    @ResponseBody
    public R save(String smsCode, @RequestBody TbUser tbUser) {
        userServiceFeign.save(tbUser, smsCode);
        return  R.ok().message("恭喜您，注册成功");
    }

}
